package com.roy.galaxy.algorithm;

/**
 * @author gang.wang1903@xiaobao100.cn
 * @Date: 2019-10-28 09:58
 */
public class 回文数 {


    public boolean isPalindrome(int x) {

        int flag = 0;

        StringBuffer stringBuffer = new StringBuffer();
        while (flag == 0){
            int temp = x/10;
            int y = x % 10;
            stringBuffer.append(y);
            x =temp;
            if(x == 0){
                flag = 1;
            }
        }

        for(int i = 0 ; i < stringBuffer.length() / 2 ; i ++){
            if(!(stringBuffer.charAt(i) == stringBuffer.charAt(stringBuffer.length() - 1 -i))){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new 回文数().isPalindrome(121));
    }

}
